home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / debug / GAngelRmx1_1.lha / GuardianAngelRemix / source / FlushAngel.s < prev    next >
Text File  |  1998-02-11  |  4KB  |  243 lines

  1.  
  2. ;Blind    equ    0
  3.  
  4.     super
  5. ;    addsym
  6.     MC68040
  7.     bopt    f+,x+,O+,wo-,OG+
  8. ;    output    yo:FlushAngel
  9.     output    ram:GuardianAngelRemix/FlushAngel
  10.  
  11.     incdir    includes:
  12.     include    exec/exec.i
  13.     include    offsets/exec_lib.i
  14.     include    offsets/dos_lib.i
  15.     include    dos/dos.i
  16.     include    dos/dosextens.i
  17.     include    macros:macros
  18.  
  19.  
  20. GETURP    macro
  21.     ifnd    mmu030
  22.         movec    TC,\1
  23.         tst.w    \1
  24.         bmi.b    .ok\@
  25.  
  26.         sub.l    \1,\1
  27.         bra.b    .nogo\@
  28. .ok\@
  29.         move.l    \1,-(sp)
  30.         btst.b    #6,2(sp)    ; TCR bit 14
  31.         addq.l    #4,sp
  32.         beq.b    .ok2\@
  33.  
  34.         sub.l    \1,\1
  35.         bra.b    .nogo\@
  36. .ok2\@
  37.         movec    URP,\1
  38. .nogo\@
  39.     else
  40.         subq.l    #8,sp
  41.         pmove.q    CRP,(sp)
  42.         and.b    #$f0,7(sp)
  43.         move.l    4(sp),\1
  44.         addq.l    #8,sp
  45.     endc                    ; -1
  46.     endm
  47.  
  48. UP    macro
  49.     add.l     #$fff,\1
  50.     ifeq    NARG-2
  51.     add.l     #$fff,\2
  52.     endc
  53.     and.w    #~$fff,\1
  54.     ifeq    NARG-2
  55.     and.w    #~$fff,\2
  56.     endc
  57.     endm
  58.  
  59. DOWN    macro
  60.     and.w    #~$fff,\1
  61.     endm
  62.  
  63. CodeStart
  64.     move.l    4.w,a6
  65.     moveq    #1,d7
  66.     btst.b    #AFB_68040,AttnFlags+1(a6)
  67.     beq.b    ExitAngel
  68.  
  69.     sub.l    a1,a1
  70.     jsr    _LVOFindTask(a6)
  71.  
  72.     move.l    d0,a4
  73.     tst.l    pr_CLI(a4)    ; was it called from CLI?
  74.     bne    .fromCLI    ; if so, skip out this bit...
  75.  
  76.     lea    pr_MsgPort(a4),a0
  77.     jsr    _LVOWaitPort(A6)
  78.     lea    pr_MsgPort(a4),a0
  79.     jsr    _LVOGetMsg(A6)
  80.     lea    (returnMsg,pc),a0
  81.     move.l    d0,(a0)
  82.  
  83. .fromCLI
  84.  
  85.     lea    (EXECBase,pc),a0
  86.     move.l    a6,(a0)
  87.  
  88.     lea    (.super,pc),a5
  89.     SYS    Supervisor
  90.     bra    .goturp
  91. .super    GETURP    d0
  92.     rte
  93. .goturp
  94.     moveq    #2,d7
  95.     tst.l    d0
  96.     beq    ExitAngel
  97.  
  98.     move.l    d0,d6
  99.  
  100.     moveq    #3,d7
  101.  
  102.     ifnd    Blind
  103.     SYS    Forbid
  104.  
  105.     move.l    #MEMF_REVERSE,d1
  106.     move.l    #$4000,d0
  107.     SYS    AllocMem
  108.     move.l    d0,d2
  109.     beq.b    .out
  110.  
  111.     move.l    d2,a1
  112.     move.l    #$4000,d0
  113.     SYS    FreeMem
  114.  
  115.     add.l    #$2000,d2
  116.     clr.w    d2
  117.     move.l    d2,d0
  118.     move.l    d6,a0
  119.     bsr    FindDescriptor
  120.     clr.w    d0
  121.     cmp.l    d0,d2
  122.     beq.b    .out
  123.     endc
  124.  
  125. ;    moveq    #0,d7
  126.     move.l    a6,a1
  127.     SYS    RemTask
  128.  
  129.     ifnd    Blind
  130. .out
  131.     SYS    Permit
  132.     endc
  133.  
  134. ExitAngel
  135.     bsr    WB_Exit
  136.  
  137.     lea    (Needs040,pc),a2
  138.     cmp.l    #1,d7
  139.     beq.b    .info
  140.  
  141.     lea    (MMUproblem,pc),a2
  142.     cmp.l    #2,d7
  143.     beq.b    .info
  144.  
  145.     lea    (PatchProb,pc),a2
  146.     cmp.l    #3,d7
  147. ;    beq.b    .info
  148.     bne.b    .exit
  149.  
  150. .info
  151.     bsr    UserFeedback
  152. .exit
  153.     moveq    #20,d0
  154.     rts
  155.  
  156. UserFeedback
  157.     OpenLib    Dos,.window_done
  158.     lea    (windowname,pc),a0
  159.     move.l    a0,d1
  160.     move.l    #MODE_NEWFILE,d2
  161.     DOS    Open
  162.     move.l    d0,d4
  163.     beq.b    .window_done
  164.  
  165.     move.l    d4,d1
  166.     move.l    a2,d2
  167.     move.l    a2,a0
  168. .loop    tst.b    (a0)+
  169.     bne.b    .loop
  170.  
  171.     sub.l    a2,a0
  172.     move.l    a0,d3
  173.  
  174.     SYS    Write
  175.  
  176.     move.l    d4,d1
  177.     SYS    Close
  178. .window_done
  179.     move.l    (EXECBase,pc),a6
  180.     rts
  181.  
  182. windowname    dc.b    "CON:000/000/640/100/Error information/AUTO/CLOSE/WAIT/SMART",0
  183. Needs040    dc.b    "This program only works on a 68040.",0
  184. MMUproblem    dc.b    "MMU is not in use. Please run SetPatch/Enforcer.",0
  185. DosName        dc.b    "dos.library",0
  186. PatchProb    dc.b    "Could not restore all Exec functions.",0
  187.     even
  188.  
  189. WB_Exit
  190.     move.l    (returnMsg,pc),d0    ; Is there a message?
  191.     beq    .exitToDOS        ; if not, skip...
  192.  
  193.         jsr    _LVOForbid(a6)          ; note! No Permit needed!
  194.     move.l    d0,a1
  195.     jsr    _LVOReplyMsg(a6)
  196.     jsr    _LVOPermit(a6)
  197.  
  198. .exitToDOS
  199.     rts
  200.  
  201.  
  202. returnMsg    dc.l    0
  203.  
  204. EXECBase    dc.l    0
  205. DosBase        dc.l    0
  206.  
  207.  
  208. FindDescriptor
  209. ;-Input:-----------------------------------------------------------------------
  210. ;    d0 = address    no alignment needed
  211. ;    a0 = URP
  212. ;-Output:----------------------------------------------------------------------
  213. ;    d0 = page descriptor for address
  214. ;    a0 = address of page descriptor
  215. ;------------------------------------------------------------------------------
  216.     move.l    d0,d1
  217.     swap    d1
  218.     lsr.w    #7,d1        ; top 7 bits
  219.     and.b    #%11111100,d1    ; d1 = root index    ;clear bit 0,1
  220. * level 1
  221.     move.l    (a0,d1.w),d1    ; root level tables
  222.     and.w    #$fe00,d1    ; clear lower 9 bits
  223.     move.l    d1,a0
  224.     move.l    d0,d1
  225.     swap    d1
  226.     and.w    #%0000000111111100,d1    ; pointer index
  227. * level 2
  228.     move.l    (a0,d1.w),d1    ; pointer level tables
  229.     clr.b    d1        ; clear lower  8 bits
  230.     move.l    d1,a0
  231.  
  232.     move.l    d0,d1
  233.     lsl.l    #6,d1
  234.     swap    d1
  235.     and.w    #%0000000011111100,d1    ; d1 = table offset
  236. * level 3
  237.     lea    (a0,d1.w),a0
  238.     move.l    (a0),d0        ; page descriptor
  239.  
  240.     rts
  241.  
  242. End
  243.